<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	template="/template/LayoutDev.xhtml">


	<f:metadata>
		<f:viewAction action="#{tarefaController.buscarTodasTarefa}" />
	</f:metadata>


	<ui:define name="content">
		<f:metadata>
		<f:event type="preRenderView" listener="#{loginController.testeSessaoDev}"/> 
	</f:metadata>
		<p:panel id="prjHeader" header="Projeto">
			<h:outputText id="prjId"
				value="#{projetoController.projetoSelecionado.nome}" />
		</p:panel>

		<p:tabView id="tbvGerenciaDeProjeto">
			<p:tab title="Dados Projeto">

				<h:form id="formDadosProjeto">
					<h:panelGrid columns="1" cellpadding="5" style="width:32%;text-align: center;">


						<p:fieldset legend="Cliente" >
							<h:panelGrid columns="2" style="width:100%; height:50%" cellpadding="5">
								<p:graphicImage value="/images/personal.png"/>
								<h:inputHidden></h:inputHidden>
								<h:outputText value="Nome: #{projetoController.projetoSelecionado.cliente.nome}" />
								<h:inputHidden></h:inputHidden>
								<h:outputText value="NickName: #{projetoController.projetoSelecionado.cliente.login}" />
							</h:panelGrid>
						</p:fieldset>
						
					 <p:fieldset legend="Situação do projeto: " >
							<h:outputText value="#{projetoController.projetoSelecionado.status}" style="color:green;font-weight: bold;" rendered="#{projetoController.projetoSelecionado.status == 'Concluído'}" />
							<h:outputText value="#{projetoController.projetoSelecionado.status}" style="color:blue;font-weight: bold;" rendered="#{projetoController.projetoSelecionado.status == 'Em Desenvolvimento'}" />
							<h:outputText value="#{projetoController.projetoSelecionado.status}" style="color:red;font-weight: bold;" rendered="#{projetoController.projetoSelecionado.status == 'Não Iniciado'}" />
					</p:fieldset>
					
						<p:fieldset legend="Scrum Master" >
							<h:panelGrid columns="2" style="width:100%; height:50%" cellpadding="5">
								<p:graphicImage value="/images/personal.png"/>
								<h:inputHidden></h:inputHidden>
								<h:outputText value="Nome: #{projetoController.projetoSelecionado.scrumMaster.nome}" />
								<h:inputHidden></h:inputHidden>
								<h:outputText value="NickName: #{projetoController.projetoSelecionado.scrumMaster.login}" />
							</h:panelGrid>
						</p:fieldset>

						<p:fieldset legend="Desenvolvedores: " >

						<p:carousel value="#{projetoController.projetoSelecionado.listaDesenvolvedores}" var="dev"
							easing="easeOutBounce">
							<h:panelGrid  columns="2" style="width:100%; height:50%" cellpadding="5">
								<p:graphicImage value="/images/personal.png"/>
								<h:inputHidden></h:inputHidden>
								<h:outputText value="Nome: #{dev.nome}" />
								<h:inputHidden></h:inputHidden>
								<h:outputText value="NickName: #{dev.login}" />
							</h:panelGrid>
						</p:carousel>
						
					</p:fieldset>
					


					</h:panelGrid>
				</h:form>


			</p:tab>

			<p:tab title="BackLog">

				<p:fieldset title="Requisitos">

					<h:form id="formListaRequisitos">

						<p:dataGrid var="tarefa"
							value="#{tarefaController.tarefaPorProjeto}" columns="3"
							rows="12" paginator="true"
							paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
							rowsPerPageTemplate="9,12,15">

							<p:panel header="#{tarefa.nome}" style="text-align:center">


								<h:panelGrid columns="1" style="width:100%">

									<p:commandButton update=":tbvGerenciaDeProjeto:dialog"
										icon="ui-icon-pencil" title="View"
										oncomplete="PF('dlgDadostarefa').show();">
										<f:setPropertyActionListener value="#{tarefa}"
											target="#{tarefaController.tarefaSelecionada}" />
									</p:commandButton>

									<p:growl id="grow" showDetail="true" />

								</h:panelGrid>
							</p:panel>

						</p:dataGrid>
					</h:form>
					<p:dialog id="dialog" widgetVar="dlgDadostarefa" showEffect="clip"
						hideEffect="clip" modal="true" appendTo="@(body)" width="350"
						height="250">

						<h:form id="formDialog">
							<p:outputPanel id="detail" style="text-align:center;"
								layout="block">

								<h:panelGrid columns="2" cellpadding="5">

									<h:outputText value="Nome da Tarefa: " />
									<h:outputText id="trfNome"
										value="#{tarefaController.tarefaSelecionada.nome}" />

									<h:outputText value="Prioridade:" />
									<p:rating
										value="#{desenvolvedorTarefaController.tarefa.prioridade}" />

									<h:outputText value="Dificuldade:" />
									<h:panelGrid columns="1" style="margin-bottom:10px">
										<p:inputText id="txtDificuldade"
											value="#{desenvolvedorTarefaController.tarefa.dificuldade}" />
										<p:slider for="txtDificuldade" step="10" />
									</h:panelGrid>

									<h:outputLabel for="spinnerStep" value="Tempo de Execução: " />
									<p:spinner id="spinnerStep"
										value="#{desenvolvedorTarefaController.tarefa.tempo_execucao}"
										stepFactor="0.5" prefix="Horas: " min="0" />

								</h:panelGrid>
								<p:commandButton value="Enviar Dados" image="ui-icon-check"
									actionListener="#{desenvolvedorTarefaController.salvarDados}"
									update=":tbvGerenciaDeProjeto:formListaRequisitos"
									process="@form" >
									
									<f:attribute name="tarefaSelecionada" value="#{tarefaController.tarefaSelecionada}" />
									<f:attribute name="tarefaSelecionadaDev" value="#{tarefaController.tarefaSelecionada.desenvolvedor}" />
								</p:commandButton>
							</p:outputPanel>
						</h:form>
					</p:dialog>
				</p:fieldset>



			</p:tab>


			<p:tab title="TaskBoard">
				<h:form id="taskBoardForm">
					<h:panelGrid columns="3" styleClass="panelGrid" id="gridMain">
						<p:fieldset id="todoColumn" legend="TO DO">

							<p:outputPanel id="dropAreaTodo">

								<p:dataGrid id="todoGrid" var="tarefa"
									value="#{taskBoardController.tarefasTodo}" columns="3"
									style="width:33%">

									<p:column>
									
										<p:panel id="pnl" header="#{tarefa.nome}"
											style="text-align:center">
											
											<c:set var="valor" value="#{tarefa.desenvolvedor.id_pessoa}"></c:set>
											<c:if test="#{loginController.usuarioLogado.id_pessoa != tarefa.desenvolvedor.id_pessoa}">
												<p:draggable for="pnl" opacity="0.5" revert="true"
													handle=".ui-panel-titlebar" stack=".ui-panel" scope="doing" />
											</c:if>
											
											
										</p:panel>
									</p:column>

								</p:dataGrid>

							</p:outputPanel>

						</p:fieldset>

						<p:fieldset id="inprocessColumn" legend="In Process">

							<p:outputPanel id="dropAreaInprocess">

								<p:dataGrid id="inprocessGrid" var="tarefa"
									value="#{taskBoardController.tarefasInprocess}" columns="3"
									style="width:33%">

									<p:column>
										<p:panel id="pnl" header="#{tarefa.nome}"
											style="text-align:center">
											<p:draggable for="pnl" revert="true"
												handle=".ui-panel-titlebar" stack=".ui-panel" scope="done" />
										</p:panel>
									</p:column>

								</p:dataGrid>

							</p:outputPanel>

						</p:fieldset>

						<p:fieldset id="doneColumn" legend="Done !">

							<p:outputPanel id="dropAreaDone">

								<p:dataGrid id="doneGrid" var="tarefa"
									value="#{taskBoardController.tarefasDone}" columns="3"
									style="width:33%">

									<p:column>
										<p:panel id="pnl" header="#{tarefa.nome}"
											style="text-align:center">
											<p:draggable for="pnl" revert="true"
												handle=".ui-panel-titlebar" stack=".ui-panel" scope="todo" />
										</p:panel>
									</p:column>

								</p:dataGrid>

							</p:outputPanel>

						</p:fieldset>

						<p:droppable for="dropAreaTodo" tolerance="touch"
							activeStyleClass="ui-state-highlight" datasource="doneGrid"
							scope="todo">
							<p:ajax listener="#{taskBoardController.onDropTodo}"
								update="taskBoardForm" />
						</p:droppable>

						<p:droppable for="dropAreaInprocess" tolerance="touch"
							activeStyleClass="ui-state-highlight" datasource="todoGrid"
							scope="doing">
							<p:ajax listener="#{taskBoardController.onDropDoing}"
								update="taskBoardForm" />
						</p:droppable>

						<p:droppable for="dropAreaDone" tolerance="touch"
							activeStyleClass="ui-state-highlight" datasource="inprocessGrid"
							scope="done">
							<p:ajax listener="#{taskBoardController.onDropDone}"
								update="taskBoardForm :tbvGerenciaDeProjeto:burndownForm" />
						</p:droppable>
					</h:panelGrid>
				</h:form>

			</p:tab>
			<p:tab title="Burndown">
				<h:form id="burndownForm">
					<p:lineChart value="#{burndownController.burnDownChart}"
						legendPosition="e" zoom="true" animate="true"
						title="Burndown Chart"
						style="width:100%; height:100%; text-align:center;" />
				</h:form>

			</p:tab>
		</p:tabView>
	</ui:define>
</ui:composition>